package com.lauroc.basic.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    private Boolean success=true;

    private String message="OK";

    private String code=PetHomeConstant.SYSTEM_SUCCESS;

    private Object data;

    /**
     * 返回成功，不携带数据
     */
    public static AjaxResult createSuccess(){
        return new AjaxResult();
    }

    /**
     * 返回成功，携带数据
     */

    public static AjaxResult createSuccess(Object data){
        return new AjaxResult(true,"Ok",PetHomeConstant.SYSTEM_SUCCESS,data);
    }
    /**
     * 返回异常，自定义code用这个方法
     */
    public static AjaxResult createError(String code,String message){

        return new AjaxResult(false,message,code,null);
    }

    /**
     * 返回系统错误
     */
    public static AjaxResult createError(String message){

        return createError(PetHomeConstant.SYSTEM_ERROR,message);
    }
}
